﻿<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                xmlns:sp="http://schemas.microsoft.com/sharepoint/"
                exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>

  <!--
===================================================================================================================
  Onglet [Définition de liste]
===================================================================================================================
-->
  <xsl:template name="Onglet_ListDef">
    <Worksheet ss:Name="Définition de liste">
      <Table>
        <Row>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">...</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Type</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Url</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Title</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">XslLink</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">RowLimit</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">FeatureId</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">FeatureName</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">SolutionId</Data>
          </Cell>
        </Row>
        <xsl:apply-templates select="//List"/>
      </Table>
      <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"/>
    </Worksheet>
  </xsl:template>

  <!--
===================================================================================================================
  Template [List]
===================================================================================================================
-->
  <xsl:template match="List">
    <Row ss:StyleID="mainLine">
      <Cell>
        <Data ss:Type="String">List</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Type"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Url"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Title"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="XslLink/text()"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="RowLimit/text()"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'Feature']/@Id"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'Feature']/@Title"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'Solution']/@Id"/>
        </Data>
      </Cell>
    </Row>

    <!--Colonnes de la liste-->
    <Row>
      <Cell>
        <Data ss:Type="String">...</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">ID</Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">Type</Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">Name</Data>
      </Cell>
    </Row>
    <xsl:apply-templates select="Fields/Field" mode="ListField"/>

    <!--Vues de la liste-->
    <Row>
      <Cell>
        <Data ss:Type="String">...</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">BaseViewID</Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">DisplayName</Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">Url</Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">SetupPath</Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">DefaultView</Data>
      </Cell>
    </Row>
    <xsl:apply-templates select="Views/View"/>

  </xsl:template>

  <!--
===================================================================================================================
  Template [Field]
===================================================================================================================
-->
  <xsl:template match="Field" mode="ListField">
    <Row>
      <Cell>
        <Data ss:Type="String">Field</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@ID"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Type"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Name"/>
        </Data>
      </Cell>
    </Row>
  </xsl:template>

  <!--
===================================================================================================================
  Template [View]
===================================================================================================================
-->
  <xsl:template match="View">
    <Row>
      <Cell>
        <Data ss:Type="String">View</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@BaseViewID"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@DisplayName"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Url"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@SetupPath"/>
        </Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@DefaultView"/>
        </Data>
      </Cell>
    </Row>

    <!--Colonnes de la vue-->
    <Row>
      <Cell>
        <Data ss:Type="String">...</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell ss:StyleID="subHeaderStyle">
        <Data ss:Type="String">FieldRefName</Data>
      </Cell>
    </Row>
    <xsl:apply-templates select="ViewFields/FieldRef" mode="ViewFieldRef"/>
  </xsl:template>

  <!--
===================================================================================================================
  Template [FieldRef]
===================================================================================================================
-->
  <xsl:template match="FieldRef" mode="ViewFieldRef">
    <Row>
      <Cell>
        <Data ss:Type="String">FieldRef</Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell>
        <Data ss:Type="String"></Data>
      </Cell>
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Name"/>
        </Data>
      </Cell>
    </Row>
  </xsl:template>

</xsl:stylesheet>
